package wli.web.util;

import java.util.*;

public class MyJavaScript {
    /*
    public static StringBuffer resizeImage(String image_name, int max_width, int max_height, String script_name) {
	StringBuffer sbf = new StringBuffer();
	sbf.append("<SCRIPT>");
	sbf.append("function "+script_name+"() {");
	sbf.append("   var w = document.image_name.width;");
	sbf.append("   var h = document.image_name.height;");
	sbf.append("   while (w > "+max_width+") {");
	sbf.append("	   w = w*0.9;");
	sbf.append("	   h = h*0.9;");
	sbf.append("   };");
	sbf.append("   document.images[1].width =w;");
	sbf.append("   document.images[1].height=h;");
	sbf.append("   parent.document.forms.postform.image"+which+".value=\""+image+"\";");
	sbf.append("   parent.document.forms.postform.image_width"+which+".value=w;");
	sbf.append("   parent.document.forms.postform.image_height"+which+".value=h;");
	sbf.append("   if(w==0 || h==0) {");
	sbf.append("      location.reload(true);");
	sbf.append("   }");
	sbf.append("}");
	sbf.append("</SCRIPT>");
	return sbf;
    }
    */
    public static StringBuffer getImageOnError(String f_name) {
	StringBuffer sb = new StringBuffer();
	sb.append("<SCRIPT>");
	sb.append("function "+f_name+"(which) {");
	sb.append("  which.src=\"/images/error.gif\";");
	sb.append("}");
	sb.append("</SCRIPT>");
	return sb;
    }

    public static StringBuffer displayHistory () {
	StringBuffer sbf = new StringBuffer();
	sbf.append("<SCRIPT>");
	//sbf.append("netscape.security.PrivilegeManager.enablePrivilege(\"UniversalBrowserRead\");");
	sbf.append("for (var i=0; i<window.history.length; i++) {");
	sbf.append("  document.write(\"<BR>\"+i+\"=\"+window.history[i]);");
	sbf.append("}");
	sbf.append("</SCRIPT>");
	return sbf;
    }

    public static StringBuffer disableHistory () {
	StringBuffer sbf = new StringBuffer();
	sbf.append("<SCRIPT>");
	sbf.append("window.history.forward(1);");
	sbf.append("</SCRIPT>");
	return sbf;
    }
}



